package xrz.xuanbao.modular.mine.baoku;

import java.util.Date;

import org.xutils.x;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ProgressBar;
import joanzapata.android.BaseAdapterHelper;
import joanzapata.android.QuickAdapter;
import xrz.cuanbao.R;
import xrz.cuanbao.utils.DateKit;

public class Adapter_YongYou extends QuickAdapter<MyBaoku> {


	public Adapter_YongYou(Context context, int layoutResId) {
		super(context, layoutResId);
	}

	@Override
	protected void convert(BaseAdapterHelper arg0, final MyBaoku arg1) {
		String strtime;
		try {
			long time = Long.parseLong(arg1.addtime);
			Date date = new Date(time * 1000);
			strtime = DateKit.friendlyFormat(date);
		} catch (Exception e) {
			strtime = arg1.addtime;
		}
		arg0.setText(R.id.tv_time, strtime).setText(R.id.tv_title, arg1.title).setText(R.id.tv_progress, arg1.percent).setText(R.id.tv_number, arg1.number).setText(R.id.tv_jine, arg1.amount+"Ԫ");
		ProgressBar progressBar = arg0.getView(R.id.progressbar);
		progressBar.setMax(100);
		progressBar.setProgress(Math.round(Float.parseFloat(arg1.percent)));
		ImageView Img = arg0.getView(R.id.img_logo);
		x.image().bind(Img, arg1.thumb);
		Button Btn_TuiKuan=arg0.getView(R.id.btn_tuikuan);
		Button btn_seedetail=arg0.getView(R.id.btn_seedetail);
		btn_seedetail.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
//				m_Context.startActivity(new Intent(m_Context, Act_PaipaibaoDetail.class));
			}
		});
		Btn_TuiKuan.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent intent = new Intent(context,Act_BaoKuTuiKuan.class);
				intent.putExtra("orderid", arg1.orderid);
				intent.putExtra("jine", arg1.amount);
				 context.startActivity(intent);		
			}
		});		
	}

}
